{% extends 'base.html' %}

{% block style %}
    <link rel="stylesheet" type="text/css" href="/static_media/css/main/search.css">
{% endblock style %}

{% block script %}
{% endblock script %}

{% block content %}
    	<div class="formItem">
            <form method="get" action=".">
				<div class="fieldError"> {{ item.non_field_errors }} </div>
				<div id="searchField">
					<label for="id_q" class="fieldHeading" ></label>
					<div class="fieldError"> {{ form.q.errors }} </div>
					<div class="fieldWrapper"> {{ form.q }} </div>
					<input type="submit" value="  search  " id="searchButton" class="button"/>
				</div>
				<label for="id_models" class="fieldHeading" >Filter Search By:</label>
				<div class="modelsFieldWrapper"> {{ form.models }} </div>
            </form>
        </div>
        {% if query %}
		
			{% if page.object_list %}
				{% for result in page.object_list %}
					{% if result.content_type == "main.outcrop" %}
					<div class="item">
						<div class="headingContainer">
							<div class="smallHeading"> 
								<a href="/outcrop/{{result.object.pk}}/">{{result.object.name}}</a>
							</div>
						</div>
						<div class="description">
							{{result.object.description|linebreaksbr}}
						</div>
					</div>
					{% endif %}
					{% if result.content_type == "main.excursion" %}
					<div class="item">
						<div class="headingContainer">
							<div class="smallHeading"> 
								<a href="/user/excursion/{{result.object.pk}}/">{{result.object.name}}</a>
							</div>
							<div class="join">
								<form method="post" action="/user/excursion/join/{{result.object.pk}}/"> {% csrf_token %}
									<input type="submit" value="Join" id="joinButton" class="button"/>
								</form>
							</div>
						</div>
						<div class="description">
							{{result.object.description|linebreaksbr}}
						</div>
					</div>
					{% endif %}
			   {% endfor %}
			{% else %}
				<div class="item">
                	<div class="smallHeading"> 
                    	No results found.
                    </div>
                </div>
			{% endif %}
			
        	{% if page.has_previous or page.has_next %}
                <div class ="item">
                    {% if page.has_previous %}<a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Previous{% if page.has_previous %}</a>{% endif %}
                    |
                    {% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}Next &raquo;{% if page.has_next %}</a>{% endif %}
                </div>
            {% endif %}
			
       	{% endif %}
{% endblock %}